// import { color } from 'html2canvas/dist/types/css/types/color'

// set function parseTime,formatTime to filter
export { parseTime, formatTime } from '@/utils'

function pluralize(time, label) {
  if (time === 1) {
    return time + label
  }
  return time + label + 's'
}

export function timeAgo(time) {
  const between = Date.now() / 1000 - Number(time)
  if (between < 3600) {
    return pluralize(~~(between / 60), ' minute')
  } else if (between < 86400) {
    return pluralize(~~(between / 3600), ' hour')
  } else {
    return pluralize(~~(between / 86400), ' day')
  }
}

/* 数字 格式化*/
export function numberFormatter(num, digits) {
  const si = [
    { value: 1E18, symbol: 'E' },
    { value: 1E15, symbol: 'P' },
    { value: 1E12, symbol: 'T' },
    { value: 1E9, symbol: 'G' },
    { value: 1E6, symbol: 'M' },
    { value: 1E3, symbol: 'k' }
  ]
  for (let i = 0; i < si.length; i++) {
    if (num >= si[i].value) {
      return (num / si[i].value + 0.1).toFixed(digits).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + si[i].symbol
    }
  }
  return num.toString()
}

export function toThousandFilter(num) {
  return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
}

export const tableColor = {
  background: '#EDF9FF', color: '#606266'
}

export const tableColorDetail = {
  background: '#cfefff', color: '#606266'
}

export const titleColor = {
   color:'#363636',fontSize:'20px',backgroundColor:'#F2F2F2',padding: '5px 11px',borderRadius: '8px'
}

export const exportColor = {
  // color:'#409EFF',fontSize:'18px',backgroundColor:'#F2F2F2',padding: '5px 11px',borderRadius: '8px'
}

export const buttonColor = {
  // 授权
  impower:'#6651de',
  //添加
  add:'#45A223',
  //编辑
  edit:'#247CAA',
  // 注销
  cancellation:'#93989b',
  // 危险代码管理
  dangerCode: '#c18c17',
  // 还原
  reduction:'#1da7bd',
  //审核
  examine:'#7399E0',
  //打印
  print:'#c7a58d',
  //生成打印
  addprint:'#9d9087',
  //删除
  delete:'#EA8723',
  //作废
  invalid: '#e7504c',
  //查找
  lookup:'#247CAA',
  //查看
  see:'#409EFF',
  //导入
  import:'#CD853F',
  //导出
  export:'#EA8723',
  //确认
  confirm:'#247CAA',
  //取消
  cancel:'#B4B4B4',
  //评估
  assessment:'#FFDAB9',
  //更新
  update:'#FFDAB9',
  //派工
  dispatch:'#375830',
  //颜色
  color:'#fff',
  colorone:'#fff',
  colornow:'#e3d0b3',
   // 预约中
   order: '#45A223',
  // 已准核
  approval: '#247CAA',
  // 已拒绝
  refused: '#EA8723',
  //取消
  rcancel:'#B4B4B4',
  // 密码重置
  pwd: "#45A223",
  // table高度(搜索栏一行)
  clientHeight: document.documentElement.clientHeight-190,
  // table高度(搜索栏两行)
  clientHeightTwo: document.documentElement.clientHeight-232,
  // table高度(搜索栏三行)
  clientHeightThree: document.documentElement.clientHeight-300,
  // 用户类型前端
  typefront: '#7399E0',
  // 用户类型后端
  typeback: '#505BDB',
  // 用户类型全部
  typeall: '#4D94B9',
  // 状态禁用
  statedisable: '#D83737',
  // 状态启用
  statestart: '#45A223',
  // 单据状态待确认
  itemisconfirmed: '#C97613',
  // 单据状态已确认
  itemconfirmed: '#008658',
  // 单据状态已作废
  iteminvalid: '#B7B7B7',
  provinceColor: '#409EFF',
  cityColor: '#67c23a',
  areaColor: '#e6a23c',

  // table宽度
  // 序号
  line: '60',
  // 状态
  state: '80',
  // 编号
  billno: '160',
  // 名称
  name: '200',
  // 人员
  user: '120',
  // 日期
 date: '100',
  // 数字
  num: '70',
  // 操作 一个按钮
  operationOne: '90',
  // 操作 两个按钮
  operationTwo: '150',
  // 操作 三个按钮
  operationThree: '200',
  // 操作 四个按钮
  operationFour: '250',

  // 实验室预约
  // 预约
  yuyue: '#33ea23',
  // 物料
  material: '#2bbef9',
  // 指令
  instruction: '#9d44dc',
  // 参数
  parameter: '#c3d217',
  // 人员
  person: '#33ea23',
  // 实验室
  lab: '#2bbef9',
  // 标签
  tag: '#d910ae',
}
